package javolution.xml.stream;

import java.io.OutputStream;
import java.io.Writer;
import javolution.context.ObjectFactory;
import javolution.lang.Configurable;

/* loaded from: classes2.dex */
public abstract class XMLOutputFactory {
    public static final String AUTOMATIC_EMPTY_ELEMENTS = "javolution.xml.stream.automaticEmptyElements";
    public static final String INDENTATION = "javolution.xml.stream.indentation";
    public static final String IS_REPAIRING_NAMESPACES = "javolution.xml.stream.isRepairingNamespaces";
    public static final String REPAIRING_PREFIX = "javolution.xml.stream.repairingPrefix";
    public static final Configurable<Class<? extends XMLOutputFactory>> DEFAULT = new Configurable<>(Default.CLASS);
    private static final ObjectFactory XML_WRITER_FACTORY = new ObjectFactory() { // from class: javolution.xml.stream.XMLOutputFactory.1
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public void cleanup(Object obj) {
            ((XMLStreamWriterImpl) obj).reset();
        }

        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return new XMLStreamWriterImpl();
        }
    };

    /* loaded from: classes2.dex */
    private static final class Default extends XMLOutputFactory {
        static final Class CLASS = new Default().getClass();
        private Boolean _automaticEmptyElements;
        private String _indentation;
        private Boolean _isRepairingNamespaces;
        private String _repairingPrefix;

        private Default() {
            this._isRepairingNamespaces = new Boolean(false);
            this._repairingPrefix = "ns";
            this._automaticEmptyElements = new Boolean(false);
        }

        private XMLStreamWriterImpl newWriter() {
            XMLStreamWriterImpl xMLStreamWriterImpl = (XMLStreamWriterImpl) XMLOutputFactory.XML_WRITER_FACTORY.object();
            xMLStreamWriterImpl._objectFactory = XMLOutputFactory.XML_WRITER_FACTORY;
            xMLStreamWriterImpl.setRepairingNamespaces(this._isRepairingNamespaces.booleanValue());
            xMLStreamWriterImpl.setRepairingPrefix(this._repairingPrefix);
            xMLStreamWriterImpl.setIndentation(this._indentation);
            xMLStreamWriterImpl.setAutomaticEmptyElements(this._automaticEmptyElements.booleanValue());
            return xMLStreamWriterImpl;
        }

        @Override // javolution.xml.stream.XMLOutputFactory
        public XMLStreamWriter createXMLStreamWriter(OutputStream outputStream) throws XMLStreamException {
            XMLStreamWriterImpl newWriter = newWriter();
            newWriter.setOutput(outputStream);
            return newWriter;
        }

        @Override // javolution.xml.stream.XMLOutputFactory
        public XMLStreamWriter createXMLStreamWriter(OutputStream outputStream, String str) throws XMLStreamException {
            if (str == null || str.equals("UTF-8") || str.equals("utf-8")) {
                return createXMLStreamWriter(outputStream);
            }
            XMLStreamWriterImpl newWriter = newWriter();
            newWriter.setOutput(outputStream, str);
            return newWriter;
        }

        @Override // javolution.xml.stream.XMLOutputFactory
        public XMLStreamWriter createXMLStreamWriter(Writer writer) throws XMLStreamException {
            XMLStreamWriterImpl newWriter = newWriter();
            newWriter.setOutput(writer);
            return newWriter;
        }

        @Override // javolution.xml.stream.XMLOutputFactory
        public Object getProperty(String str) throws IllegalArgumentException {
            if (str.equals(XMLOutputFactory.IS_REPAIRING_NAMESPACES)) {
                return this._isRepairingNamespaces;
            }
            if (str.equals(XMLOutputFactory.REPAIRING_PREFIX)) {
                return this._repairingPrefix;
            }
            if (str.equals(XMLOutputFactory.AUTOMATIC_EMPTY_ELEMENTS)) {
                return this._automaticEmptyElements;
            }
            if (str.equals(XMLOutputFactory.INDENTATION)) {
                return this._indentation;
            }
            throw new IllegalArgumentException("Property: " + str + " not supported");
        }

        @Override // javolution.xml.stream.XMLOutputFactory
        public boolean isPropertySupported(String str) {
            return str.equals(XMLOutputFactory.IS_REPAIRING_NAMESPACES) || str.equals(XMLOutputFactory.REPAIRING_PREFIX) || str.equals(XMLOutputFactory.AUTOMATIC_EMPTY_ELEMENTS) || str.equals(XMLOutputFactory.INDENTATION);
        }

        @Override // javolution.xml.stream.XMLOutputFactory
        public void setProperty(String str, Object obj) throws IllegalArgumentException {
            if (str.equals(XMLOutputFactory.IS_REPAIRING_NAMESPACES)) {
                this._isRepairingNamespaces = (Boolean) obj;
            } else if (str.equals(XMLOutputFactory.REPAIRING_PREFIX)) {
                this._repairingPrefix = (String) obj;
            } else if (str.equals(XMLOutputFactory.AUTOMATIC_EMPTY_ELEMENTS)) {
                this._automaticEmptyElements = (Boolean) obj;
            } else if (str.equals(XMLOutputFactory.INDENTATION)) {
                this._indentation = (String) obj;
            } else {
                throw new IllegalArgumentException("Property: " + str + " not supported");
            }
        }
    }

    static {
        ObjectFactory.setInstance(new ObjectFactory() { // from class: javolution.xml.stream.XMLOutputFactory.2
            /* JADX INFO: Access modifiers changed from: protected */
            @Override // javolution.context.ObjectFactory
            public Object create() {
                return new Default();
            }
        }, Default.CLASS);
    }

    protected XMLOutputFactory() {
    }

    public static XMLOutputFactory newInstance() {
        return (XMLOutputFactory) ObjectFactory.getInstance(DEFAULT.get()).object();
    }

    public abstract XMLStreamWriter createXMLStreamWriter(OutputStream outputStream) throws XMLStreamException;

    public abstract XMLStreamWriter createXMLStreamWriter(OutputStream outputStream, String str) throws XMLStreamException;

    public abstract XMLStreamWriter createXMLStreamWriter(Writer writer) throws XMLStreamException;

    public abstract Object getProperty(String str) throws IllegalArgumentException;

    public abstract boolean isPropertySupported(String str);

    public abstract void setProperty(String str, Object obj) throws IllegalArgumentException;
}
